import requests

headers = {
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"
}

# 请求数据的url
memurl = 'https://www.yaozh.com/member/'


# 需要的是  字典类型
cookie_dict = {
    "acw_tc":"2f624a5515666473010522601e1c222eab074b11914cad4b6d81177d3ec019",
    "_ga":"GA1.1.643126581.1566647363",
    "_gid":"GA1.1.1690281967.1566647363",
    "PHPSESSID":"dsiarf813ehc9mrml0hd4ruse1",
    "acw_tc":"2f624a5515666473010522601e1c222eab074b11914cad4b6d81177d3ec019",
    "_ga":"GA1.1.643126581.1566647363",
    "_gid":"GA1.1.1690281967.1566647363",
    "_gat":"1",
    "Hm_lvt_65968db3ac154c3089d7f9a4cbb98c94":"1566647302",
    "Hm_lpvt_65968db3ac154c3089d7f9a4cbb98c94":"1566647352",
    "yaozh_uidhas":"1",
    "UtzD_f52b_saltkey":"u06z66bb",
    "UtzD_f52b_lastvisit":"1566643759",
    "UtzD_f52b_ulastactivity":"1566647350%7C0",
    "yaozh_logintime":"1566658898",
    "yaozh_user":"803878%09xiaomeng_1",
    "yaozh_userId":"803878",
    "db_w_auth":"706821%09xiaomeng_1",
    "UtzD_f52b_lastact":"1566658899%09uc.php%09",
    "UtzD_f52b_auth":"02deEf1LzEQOiJTXAGsiAB93mFspzBRaPVKC8SaRX4F%2F0%2BaTOgGsnHe85eRk9cyxBPnBNImeLXWxGDJLjiCd8Bsfr1M",
    "yaozh_mylogin":"1566691825"
}


cookie_dict_1 = {}
cookies = "acw_tc=2f624a5515666473010522601e1c222eab074b11914cad4b6d81177d3ec019; _ga=GA1.1.643126581.1566647363; _gid=GA1.1.1690281967.1566647363; PHPSESSID=dsiarf813ehc9mrml0hd4ruse1; acw_tc=2f624a5515666473010522601e1c222eab074b11914cad4b6d81177d3ec019; _ga=GA1.1.643126581.1566647363; _gid=GA1.1.1690281967.1566647363; _gat=1; Hm_lvt_65968db3ac154c3089d7f9a4cbb98c94=1566647302; Hm_lpvt_65968db3ac154c3089d7f9a4cbb98c94=1566647352; yaozh_uidhas=1; UtzD_f52b_saltkey=u06z66bb; UtzD_f52b_lastvisit=1566643759; UtzD_f52b_ulastactivity=1566647350%7C0; yaozh_logintime=1566658898; yaozh_user=803878%09xiaomeng_1; yaozh_userId=803878; db_w_auth=706821%09xiaomeng_1; UtzD_f52b_lastact=1566658899%09uc.php%09; UtzD_f52b_auth=02deEf1LzEQOiJTXAGsiAB93mFspzBRaPVKC8SaRX4F%2F0%2BaTOgGsnHe85eRk9cyxBPnBNImeLXWxGDJLjiCd8Bsfr1M; yaozh_mylogin=1566691825"
cookies_list = cookies.split('; ')
for cookie in cookies_list:
    cookie_dict_1[cookie.split('=')[0]] = cookie.split('=')[1]

print(cookie_dict_1)

# 字典推导式
cookie_dict_2 = {cookie.split('=')[0]:cookie.split('=')[1] for cookie in cookies.split('; ')}
print(cookie_dict_2)



response = requests.get(memurl, headers=headers, cookies=cookie_dict_1)

data = response.content.decode('utf-8')
with open('05_cookie.html','w',encoding='utf-8') as f:
    # print(data)
    f.write(data)